package com.itlong.cloud.property.service.impl;

import com.itlong.cloud.POJO.DTO.common.NettyServiceDTO;
import com.itlong.cloud.POJO.DTO.property.CalculateCostsDTO;
import com.itlong.cloud.POJO.DTO.property.CarIssueDTO;
import com.itlong.cloud.POJO.DTO.property.PaymentParkingCostsDTO;
import com.itlong.cloud.enumerate.ParkingBusinessOrderEnum;
import com.itlong.cloud.property.dao.IParkCarHttpDao;
import com.itlong.cloud.property.service.IParkCarHttpService;
import com.itlong.cloud.utils.node.JsonUtil;
import com.itlong.cloud.utils.random.LogicIdUtil;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * <desc>
 *      物业-智慧停车-http业务交互接口实现类
 * </desc>
 *
 * @createDate 2018/11/11
 */
@Service
public class ParkCarHttpServiceImpl implements IParkCarHttpService {
    private static final Logger LOG = LoggerFactory.getLogger(ParkCarHttpServiceImpl.class); //日志对象
    @Autowired
    IParkCarHttpDao iParkCarHttpDao;

    /**
     * <desc>
     *      停车算费
     * </desc>
     *
     * @param dto
     * @return 金额
     * @author Jiaqi.X
     * @createDate 2018/11/11
     */
    @Override
    public NettyServiceDTO queryParkCarFee(CalculateCostsDTO dto) throws IOException {
        String uuId = LogicIdUtil.bussinessId();
        dto.setMessageId(uuId);
        return new NettyServiceDTO(iParkCarHttpDao.getParkingLotKey(dto.getProjectId()),JsonUtil.toJSON(dto),
                ParkingBusinessOrderEnum.QUERY_PARKING_FEE, uuId);
    }



    /**
     * <desc>
     *      缴费通知
     * </desc>
     *
     * @param dto
     * @return
     * @author Jiaqi.X
     * @createDate 2018/11/12
     */
    @Override
    public NettyServiceDTO paymentParkingFee(PaymentParkingCostsDTO dto) throws IOException {
        String uuId = LogicIdUtil.bussinessId();
        dto.setMessageId(uuId);
        return new NettyServiceDTO(iParkCarHttpDao.getParkingLotKey(dto.getProjectId()),JsonUtil.toJSON(dto),
                ParkingBusinessOrderEnum.PAY_FEE, uuId);
    }

    /**
     * <desc>
     *      缴费通知
     * </desc>
     *
     * @param dto
     * @return
     * @author Jiaqi.X
     * @createDate 2018/11/12
     */
    @Override
    public NettyServiceDTO carIssue(CarIssueDTO dto) throws IOException {
        String uuId = LogicIdUtil.bussinessId();
        dto.setMessageId(uuId);
        return new NettyServiceDTO(iParkCarHttpDao.getParkingLotKey(dto.getProjectId()),JsonUtil.toJSON(dto),
                ParkingBusinessOrderEnum.PAY_MONTHLY_CARD, uuId);
    }
}
